package com.aabte.auth.account.resource.facade.assembler;

import com.aabte.auth.account.domain.model.Account;
import com.aabte.auth.account.resource.api.auth.AuthAccountDTO;
import com.aabte.auth.group.domain.model.Group;
import com.aabte.auth.group.domain.model.GroupName;

import java.util.Set;
import java.util.stream.Collectors;

public class AuthAccountDTOAssembler {
    public AuthAccountDTO toDTO(Account account) {
        Set<String> groupNames = account.getGroups().stream()
                .map(Group::getGroupName)
                .map(GroupName::getName)
                .collect(Collectors.toSet());
        return new AuthAccountDTO(
                account.getAccountId().getId(),
                account.getAccountName().getName(),
                account.getStatus(),
                groupNames);
    }
}
